home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUTORC.ZIP / TCCFILES.ZIP / WORMIETC.C < prev   
C/C++ Source or Header  |  1994-10-30  |  10KB  |  240 lines

  1. /*
  2.   wormietc.c
  3.   use with tutsbstc.c
  4.   Version for Turbo C
  5.   10/30/94 
  6.   Adapted from tutprog4.pas, translated into C.
  7.   This version is a version of the wormie program for Turbo C. 
  8.   Compile using the batch file tccworm.bat
  9.   All the other examples are for Microsoft C.
  10.   Steve Pinault scp@ohm.att.com
  11. */
  12. // Program T_holic;
  13. #include "tcheadr.h"
  14.  
  15. char Block[40][40] = {
  16.        {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0},
  17.        {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0},
  18.        {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
  19.        {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
  20.        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  21.        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  22.        {0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0},
  23.        {0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0},
  24.        {0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0},
  25.        {0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0},
  26.        {1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1},
  27.        {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
  28.        {1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
  29.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  30.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  31.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  32.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  33.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  34.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  35.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  36.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  37.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  38.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  39.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  40.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  41.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  42.        {1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
  43.        {1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1},
  44.        {1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
  45.        {1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1},
  46.        {0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0},
  47.        {0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0},
  48.        {0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0},
  49.        {0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0},
  50.        {0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0},
  51.        {0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0},
  52.        {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0},
  53.        {0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0},
  54.        {0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0},
  55.        {0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0}
  56.        };
  57.  
  58.  
  59.    char WholePal[256][3];
  60.    int curx,cury,curcol;
  61.    int right,down;
  62.  
  63. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  64. // Procedure CunninglyManipulatePalette;
  65. //    { This moves up the pallette by one so that the color of the block
  66. //      being put down is always the same }
  67. //  Just call rotatepal(WholePal,1,210)
  68. // void CunninglyManipulatePalette()
  69. // {
  70. //    Tmp : Array[1..3] of byte;
  71. //    char Tmp:
  72. //   loop : Byte;
  73. // Begin
  74. //    Move(WholePal[210],Tmp[1],3);           { Save Last Colour             }
  75. //    Move(WholePal[1],WholePal[2],209*3);    { Move Rest Up one             }
  76. //    Move(Tmp,WholePal[1],3);                { Put Last Colour to First pos }
  77. //    For Loop := 1 to 210 do
  78. //       Pal(Loop,WholePal[Loop,1],WholePal[Loop,2],WholePal[Loop,3]);
  79. // End;
  80.  
  81.  
  82.  
  83. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  84. // Procedure PreparePalette;
  85. //    { This sets up the palette to have pretty gradients in it for our use }
  86. void PreparePalette()
  87. {
  88.    int loop;
  89.    for(loop=0;loop<30;loop++)
  90.    {
  91.       WholePal [loop][0]=loop*2;
  92.       WholePal [loop][1]=0;
  93.       WholePal [loop][2]=0;
  94.    }
  95.  
  96.    for(loop=30;loop<60;loop++)
  97.    {
  98.       WholePal [loop][0]=0;
  99.       WholePal [loop][1]=loop*2-30;
  100.       WholePal [loop][2]=0;
  101.    }
  102.  
  103.    for(loop=60;loop<90;loop++)
  104.    {
  105.       WholePal [loop][0]=0;
  106.       WholePal [loop][1]=0;
  107.       WholePal [loop][2]=loop*2-30;
  108.    }
  109.  
  110.    for(loop=90;loop<120;loop++)
  111.    {
  112.       WholePal [loop][0]=loop*2-30;
  113.       WholePal [loop][1]=loop*2-30;
  114.       WholePal [loop][2]=loop*2-30;
  115.    }
  116.  
  117.    for(loop=120;loop<150;loop++)
  118.    {
  119.       WholePal [loop][0]=loop*2-30;
  120.       WholePal [loop][1]=loop*2-30;
  121.       WholePal [loop][2]=0;
  122.    }
  123.  
  124.    for(loop=150;loop<180;loop++)
  125.    {
  126.       WholePal [loop][0]=0;
  127.       WholePal [loop][1]=loop*2-30;
  128.       WholePal [loop][2]=loop*2-30;
  129.    }
  130.  
  131.    for(loop=180;loop<210;loop++)
  132.    {
  133.       WholePal [loop][0]=loop*2-30;
  134.       WholePal [loop][1]=0;
  135.       WholePal [loop][2]=loop*2-30;
  136.    }
  137. }
  138.  
  139. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  140. // Procedure IngeniouslyMoveCurPos;
  141. //    { This moves the position of the block to put down around the screen }
  142. void IngeniouslyMoveCurPos()
  143. {
  144.    // CurCol := (CurCol) mod 210 + 1;        { This Does Work                }
  145.    curcol = 1 + curcol%210;
  146.    if(right) curx += 4; else curx -= 3;
  147.    if(down)  cury += 3; else cury -= 2;
  148.  
  149.    if(curx > 250) right = 0;
  150.    if(cury > 150) down  = 0;
  151.  
  152.    if(curx < 10)  right = 1;
  153.    if(cury < 10)  down  = 1;
  154.  
  155. }
  156.  
  157.  
  158. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  159. // Procedure DrawBlock;
  160. //    { This draws the block onto the VGA screen }
  161. void DrawBlock()
  162. {
  163.    int xloop,yloop;
  164.    for(xloop=0;xloop<40;xloop++)
  165.       for(yloop=0;yloop<40;yloop++)
  166.         if(Block[yloop][xloop] == 1)
  167.             PutPixel(curx+xloop,cury+yloop,(char)curcol,VGA);
  168. }
  169.  
  170.  
  171. // {DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD}
  172. // Procedure StartSnakiepoo;
  173. //    { This is the proc where we set things up & set em in motion! ;-) }
  174. void StartSnakiepoo()
  175. {
  176.    curx=100;
  177.    cury=100;
  178.    curcol=1;
  179.    PreparePalette();
  180.    while(1)
  181.    {
  182.       if(_bios_keybrd(_KEYBRD_READY))break;
  183.       //WaitRetrace();
  184.       DrawBlock();
  185.       rotatepal(WholePal,1,210);
  186.       // CunninglyManipulatePalette;
  187.       IngeniouslyMoveCurPos();
  188.    }
  189.    FadeDown();
  190.    getch();
  191. }
  192.  
  193. void main()
  194. {
  195.    SetMCGA();
  196.    StartSnakiepoo();
  197.    SetText();
  198. }
  199. /*
  200. Begin
  201.    ClrScr;
  202.    Writeln ('Hi there!  This is a small little routine that Livewire');
  203.    Writeln ('and Denthor of ASPHYXIA threw together during lunch break');
  204.    Writeln ('at varsity. We first saw this routine in the T-Holic demo');
  205.    Writeln ('by Extreme a few months back, and decided to write it as');
  206.    Writeln ('a supliment to the ASPHYXIA VGA Demo Trainer Series on the');
  207.    Writeln ('MailBox BBS here in Durban.                              ');
  208.    Writeln;
  209.    Writeln ('The routine consists of a wormy type thing bouncing around');
  210.    Writeln ('the screen, and looks quite effective. The code is');
  211.    Writeln ('documented, and the concept behind it is so easy everyone');
  212.    Writeln ('should be able to understand it.                         ');
  213.    Writeln;
  214.    Writeln ('The Pal routines, setmcga, waitretrace etc. are taken');
  215.    Writeln ('directly from the ASPHYXIA Trainer Series, and you should');
  216.    Writeln ('read those to understand how they work.');
  217.    Writeln;
  218.    Writeln ('See the Trainer Series for how to get into contact with us.');
  219.    Writeln; Writeln;
  220.    Writeln ('Hit any key to continue ....                             ');
  221.    Readkey;
  222.    SetMCGA;
  223.    StartSnakiepoo;
  224.    SetText;
  225.    Writeln ('All done. This was a sample routine written by ASPHYXIA.');
  226.    Writeln ('Please read the ASPHYXIA Demo Trainer Series on the MailBox BBS,');
  227.    Writeln ('written by Denthor. You may reach DENTHOR under the name of GRANT');
  228.    Writeln ('SMITH on the MailBox BBS, or leave a message to ASPHYXIA on the');
  229.    Writeln ('ASPHYXIA BBS. Get the numbers from Roblist, or write to :');
  230.    Writeln ('             Grant Smith');
  231.    Writeln ('             P.O. Box 270');
  232.    Writeln ('             Kloof');
  233.    Writeln ('             3640');
  234.    Writeln ('We hope to hear from you soon!');
  235.    Writeln; Writeln;
  236.    Write   ('Hit any key to exit ...');
  237.    Readkey;
  238. End.
  239. */
  240.